/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.taobao.ibatiside.model.mapperv3.impl;

import java.math.BigInteger;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.taobao.ibatiside.model.mapperv3.Mapperv3Package;
import org.taobao.ibatiside.model.mapperv3.ResultMap;
import org.taobao.ibatiside.model.mapperv3.ResultSetTypeType;
import org.taobao.ibatiside.model.mapperv3.Select;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Select</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.SelectImpl#getFetchSize <em>Fetch Size</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.SelectImpl#getResultMap <em>Result Map</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.SelectImpl#getResultSetType <em>Result Set Type</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.SelectImpl#getResultType <em>Result Type</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.SelectImpl#isUseCache <em>Use Cache</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SelectImpl extends AbstractStatementImpl implements Select {
	/**
	 * The default value of the '{@link #getFetchSize() <em>Fetch Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFetchSize()
	 * @generated
	 * @ordered
	 */
	protected static final Integer FETCH_SIZE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getFetchSize() <em>Fetch Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFetchSize()
	 * @generated
	 * @ordered
	 */
	protected Integer fetchSize = FETCH_SIZE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getResultMap() <em>Result Map</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResultMap()
	 * @generated
	 * @ordered
	 */
	protected ResultMap resultMap;

	/**
	 * The default value of the '{@link #getResultSetType() <em>Result Set Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResultSetType()
	 * @generated
	 * @ordered
	 */
	protected static final ResultSetTypeType RESULT_SET_TYPE_EDEFAULT = ResultSetTypeType.SCROLLINSENSITIVE;

	/**
	 * The cached value of the '{@link #getResultSetType() <em>Result Set Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResultSetType()
	 * @generated
	 * @ordered
	 */
	protected ResultSetTypeType resultSetType = RESULT_SET_TYPE_EDEFAULT;

	/**
	 * This is true if the Result Set Type attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean resultSetTypeESet;

	/**
	 * The default value of the '{@link #getResultType() <em>Result Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResultType()
	 * @generated
	 * @ordered
	 */
	protected static final String RESULT_TYPE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getResultType() <em>Result Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResultType()
	 * @generated
	 * @ordered
	 */
	protected String resultType = RESULT_TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #isUseCache() <em>Use Cache</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isUseCache()
	 * @generated
	 * @ordered
	 */
	protected static final boolean USE_CACHE_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isUseCache() <em>Use Cache</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isUseCache()
	 * @generated
	 * @ordered
	 */
	protected boolean useCache = USE_CACHE_EDEFAULT;

	/**
	 * This is true if the Use Cache attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean useCacheESet;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SelectImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Mapperv3Package.Literals.SELECT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Integer getFetchSize() {
		return fetchSize;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setFetchSize(Integer newFetchSize) {
		Integer oldFetchSize = fetchSize;
		fetchSize = newFetchSize;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.SELECT__FETCH_SIZE, oldFetchSize, fetchSize));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ResultMap getResultMap() {
		return resultMap;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setResultMap(ResultMap newResultMap) {
		ResultMap oldResultMap = resultMap;
		resultMap = newResultMap;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.SELECT__RESULT_MAP, oldResultMap, resultMap));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ResultSetTypeType getResultSetType() {
		return resultSetType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setResultSetType(ResultSetTypeType newResultSetType) {
		ResultSetTypeType oldResultSetType = resultSetType;
		resultSetType = newResultSetType == null ? RESULT_SET_TYPE_EDEFAULT : newResultSetType;
		boolean oldResultSetTypeESet = resultSetTypeESet;
		resultSetTypeESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.SELECT__RESULT_SET_TYPE, oldResultSetType, resultSetType, !oldResultSetTypeESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetResultSetType() {
		ResultSetTypeType oldResultSetType = resultSetType;
		boolean oldResultSetTypeESet = resultSetTypeESet;
		resultSetType = RESULT_SET_TYPE_EDEFAULT;
		resultSetTypeESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, Mapperv3Package.SELECT__RESULT_SET_TYPE, oldResultSetType, RESULT_SET_TYPE_EDEFAULT, oldResultSetTypeESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetResultSetType() {
		return resultSetTypeESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getResultType() {
		return resultType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setResultType(String newResultType) {
		String oldResultType = resultType;
		resultType = newResultType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.SELECT__RESULT_TYPE, oldResultType, resultType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isUseCache() {
		return useCache;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUseCache(boolean newUseCache) {
		boolean oldUseCache = useCache;
		useCache = newUseCache;
		boolean oldUseCacheESet = useCacheESet;
		useCacheESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.SELECT__USE_CACHE, oldUseCache, useCache, !oldUseCacheESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetUseCache() {
		boolean oldUseCache = useCache;
		boolean oldUseCacheESet = useCacheESet;
		useCache = USE_CACHE_EDEFAULT;
		useCacheESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, Mapperv3Package.SELECT__USE_CACHE, oldUseCache, USE_CACHE_EDEFAULT, oldUseCacheESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetUseCache() {
		return useCacheESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Mapperv3Package.SELECT__FETCH_SIZE:
				return getFetchSize();
			case Mapperv3Package.SELECT__RESULT_MAP:
				return getResultMap();
			case Mapperv3Package.SELECT__RESULT_SET_TYPE:
				return getResultSetType();
			case Mapperv3Package.SELECT__RESULT_TYPE:
				return getResultType();
			case Mapperv3Package.SELECT__USE_CACHE:
				return isUseCache();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Mapperv3Package.SELECT__FETCH_SIZE:
				setFetchSize((Integer)newValue);
				return;
			case Mapperv3Package.SELECT__RESULT_MAP:
				setResultMap((ResultMap)newValue);
				return;
			case Mapperv3Package.SELECT__RESULT_SET_TYPE:
				setResultSetType((ResultSetTypeType)newValue);
				return;
			case Mapperv3Package.SELECT__RESULT_TYPE:
				setResultType((String)newValue);
				return;
			case Mapperv3Package.SELECT__USE_CACHE:
				setUseCache((Boolean)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Mapperv3Package.SELECT__FETCH_SIZE:
				setFetchSize(FETCH_SIZE_EDEFAULT);
				return;
			case Mapperv3Package.SELECT__RESULT_MAP:
				setResultMap((ResultMap)null);
				return;
			case Mapperv3Package.SELECT__RESULT_SET_TYPE:
				unsetResultSetType();
				return;
			case Mapperv3Package.SELECT__RESULT_TYPE:
				setResultType(RESULT_TYPE_EDEFAULT);
				return;
			case Mapperv3Package.SELECT__USE_CACHE:
				unsetUseCache();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Mapperv3Package.SELECT__FETCH_SIZE:
				return FETCH_SIZE_EDEFAULT == null ? fetchSize != null : !FETCH_SIZE_EDEFAULT.equals(fetchSize);
			case Mapperv3Package.SELECT__RESULT_MAP:
				return resultMap != null;
			case Mapperv3Package.SELECT__RESULT_SET_TYPE:
				return isSetResultSetType();
			case Mapperv3Package.SELECT__RESULT_TYPE:
				return RESULT_TYPE_EDEFAULT == null ? resultType != null : !RESULT_TYPE_EDEFAULT.equals(resultType);
			case Mapperv3Package.SELECT__USE_CACHE:
				return isSetUseCache();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (fetchSize: ");
		result.append(fetchSize);
		result.append(", resultSetType: ");
		if (resultSetTypeESet) result.append(resultSetType); else result.append("<unset>");
		result.append(", resultType: ");
		result.append(resultType);
		result.append(", useCache: ");
		if (useCacheESet) result.append(useCache); else result.append("<unset>");
		result.append(')');
		return result.toString();
	}

} //SelectImpl
